require'luacom'

function RegistryWrite (key,value,type)
-- see MSDN Wscript.Shell RegWrite for documentation
  local WshShell
  WshShell = luacom.CreateObject("WScript.Shell")
  WshShell:RegWrite (key,value,type)
  WshShell = nil
  collectgarbage ()
end

function RegistryRead (key)
-- see MSDN Wscript.Shell RegRead for documentation
  local WshShell,x
  WshShell = luacom.CreateObject("WScript.Shell")
  x = WshShell:RegRead (key)
  WshShell = nil
  collectgarbage ()
  return x
end

function RegistryDelete (key)
-- see MSDN Wscript.Shell RegRead for documentation
  local WshShell,x
  WshShell = luacom.CreateObject("WScript.Shell")
  x = WshShell:RegDelete (key)
  WshShell = nil
  collectgarbage ()
end

print(RegistryRead("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Microsoft SQL Server\\90\\Cost\\MSXML6"))
RegistryWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Microsoft SQL Server\\90\\Cost\\test",
				100,"REG_DWORD"
)

RegistryDelete"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Microsoft SQL Server\\90\\Cost\\test"


function is_mssqle_installed()
	local regkey="HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SQL Server\\SQLEXPRESS\\Setup\\SQLPath"
	local finded,sqle= pcall(RegistryRead,regkey)
	print(sqle)
	if finded then
		print('find sql express @ ',sqle)
		return sqle
	end
	return nil
end
is_mssqle_installed()

